# Contributor: Dhruvin Gandhi <contact@dhruvin.dev>
# Maintainer: Dhruvin Gandhi <contact@dhruvin.dev>
pkgname=hledger-iadd
pkgver=1.3.17
pkgrel=0
pkgdesc="A terminal UI as drop-in replacement for hledger add"
url="https://github.com/hpdeifel/hledger-iadd#readme"
arch="x86_64" # limited by ghc
license="BSD-3-Clause"
makedepends="ghc cabal libffi-dev ncurses-dev"
source="https://hackage.haskell.org/package/hledger-iadd-$pkgver/hledger-iadd-$pkgver.tar.gz
	cabal.project.freeze"

export CABAL_DIR="$srcdir"/cabal

prepare() {
	default_prepare
	cp "$srcdir"/cabal.project.freeze .
}

build() {
	cabal update
	cabal build --prefix=/usr --enable-relocatable
}

check() {
	cabal test
}

package() {
	local ghcver=$(ghc --version | cut -d " " -f 8)
	install -Dm755 \
		"dist-newstyle/build/$arch-linux/ghc-$ghcver/$pkgname-$pkgver/x/$pkgname/build/$pkgname/$pkgname" \
		"$pkgdir"/usr/bin/$pkgname
}

sha512sums="
44ae987d4a2b3950a0256d52e3afabea5b3b3351f1f802e8c9a8397753d35bb9b52ae90e7046e3f2f4a46406d05cefa7d7375cb326a9f6f6001c8fd623183896  hledger-iadd-1.3.17.tar.gz
8ba67fa2a0f2ae9e938ed6f64875bf36ce5068fe6428c90731b08e4f7d7b0faf0aa5b6a9ccf9dbff5767986506b6b478b929e3cf20d93ff5949cbb0fb1c52d2b  cabal.project.freeze
"
